package com.cryrabbit.yyystitp.ui.activities;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;

import com.cryrabbit.yyystitp.R;
import com.cryrabbit.yyystitp.adapters.ViewPagerAdapter;
import com.cryrabbit.yyystitp.ui.fragments.MessageFragment;
import com.cryrabbit.yyystitp.ui.fragments.RecommendFragment;
import com.cryrabbit.yyystitp.ui.fragments.TestFragments;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;


/**
 * Created by CryRabbit on 2016/9/2.
 */

public class MainActivity extends AppCompatActivity{
    @BindView(R.id.ac_main_toolbar)
    Toolbar toolbar;
    @BindView(R.id.ac_main_tablayout)
    TabLayout tabLayout;
    @BindView(R.id.ac_main_viewpage)
    ViewPager viewPager;
    /*
    * butterknife这个绑定机制
    * */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        toolbar.setTitle("hello");
        setSupportActionBar(toolbar);
        List<Fragment> fragments=new ArrayList<>();
        List<String> titles=new ArrayList<>();
        fragments.add(new MessageFragment());
        fragments.add(new RecommendFragment());
        fragments.add(new TestFragments());
        titles.add("信息");
        titles.add("推荐");
        titles.add("我的");
        Log.i("ysm","jj");
        ViewPagerAdapter viewPagerAdapter=new ViewPagerAdapter(getSupportFragmentManager(),fragments,titles);
        viewPager.setAdapter(viewPagerAdapter);
        tabLayout.setupWithViewPager(viewPager);
    }
}
